<template>
	<account-page :title="title" :desc="desc">
		<view>
			<view class="panel-box">
				<u-cell-group :border="border">
					<view class="panel-main">
						<u-cell-item :title="item.title" :value="item.value" @click="openPage(item.path)" :border-bottom="borderBottom"
						 v-for="(item, index) in cells" :key="index"></u-cell-item>
					</view>
				</u-cell-group>

				<u-gap height="60"></u-gap>

				<view class="btn-line">
					<u-button type="error" @click="logout">退出登录</u-button>
				</view>
			</view>
		</view>
		<u-gap height="40"></u-gap>
	</account-page>
</template>

<script>
	export default {
		data() {
			return {
				title: '设置',
				desc: '',
				cells: []
			};
		},
		onShow() {
			this.getinfo();
		},
		methods: {
			getinfo() {
				this.$u.post('/wxapi/api/get_userinfo', {
					token: this.vuex_token.accessToken
					//serinfo:this.vuex_user.userinfo
				}).then(res => {
					console.log(res);
					if (res.code == 200) {
						this.cells = res.data;
					} else if (res.code == 999) {

					}
					return false;
				});
			},
			openPage(path) {
				this.$u.route({
					url: '/pages/' + path
				});
			},
			logout() {
				this.$u.vuex('vuex_user.hasLogin', false);
				this.$u.vuex('vuex_user.userId', '');
				this.$u.vuex('vuex_user.userName', '');
				this.$u.vuex('vuex_user.userFace', '');
				this.$u.toast('退出成功');
				uni.navigateBack();
			}
		}
	};
</script>

<style lang="scss" scoped>
	.panel-box {
		.panel-main {
			padding: 10rpx 0;
		}

		.btn-line {
			margin: 0 32rpx;
		}
	}

	.card-box {
		.card-main {
			margin: 0 12rpx;
			padding: 10rpx 0;
			border-radius: 16rpx;
			background-color: #ffffff;
		}

		.btn-line {
			margin: 0 40rpx;
		}
	}
</style>
